package sdl2_impl

import (
	"code.google.com/p/go8/display"
	"github.com/gonutz/go-sdl2/sdl"
)

type Image struct {
	renderer *sdl.Renderer
	texture  *sdl.Texture
}

func NewImage(r *sdl.Renderer, t *sdl.Texture) *Image {
	return &Image{r, t}
}

func (i *Image) Size() (w, h int) {
	sdl.QueryTexture(i.texture, nil, nil, &w, &h)
	return
}

func (i *Image) DrawAt(pos display.Rect) {
	i.renderer.Copy(i.texture, nil, toSdlRect(pos))
}

func toSdlRect(r display.Rect) *sdl.Rect {
	return &sdl.Rect{int32(r.X), int32(r.Y), int32(r.W), int32(r.H)}
}
